/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * mainFrame.java
 *
 * Created on Apr 3, 2011, 5:44:05 PM
 */

package GUI;

import Controller.POSController;
import javax.swing.JPanel;

/**
 *
 * @author Spence
 */
public class mainFrame extends javax.swing.JFrame {


    POSController controller;
    /** Creates new form mainFrame */
    public mainFrame(POSController control) {
        initComponents();
        controller = control;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        TitlePanel = new javax.swing.JPanel();
        LogoLabel = new javax.swing.JLabel();
        FrameTitle = new javax.swing.JLabel();
        CartPanel = new javax.swing.JPanel();
        ItemLabel = new javax.swing.JLabel();
        NumberLabel = new javax.swing.JLabel();
        LoginButton = new javax.swing.JButton();
        SearchButton = new javax.swing.JButton();
        ViewCartButton = new javax.swing.JButton();
        DynamicPanel = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        NameLabel = new javax.swing.JLabel();
        ISLabel = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("DigiStore");
        setBackground(new java.awt.Color(255, 255, 255));

        TitlePanel.setBackground(new java.awt.Color(255, 255, 255));
        TitlePanel.setPreferredSize(new java.awt.Dimension(800, 70));
        TitlePanel.setSize(new java.awt.Dimension(800, 70));

        LogoLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/GUI/Logo.png"))); // NOI18N

        FrameTitle.setFont(new java.awt.Font("Tahoma", 1, 48));
        FrameTitle.setText("Welcome");

        org.jdesktop.layout.GroupLayout TitlePanelLayout = new org.jdesktop.layout.GroupLayout(TitlePanel);
        TitlePanel.setLayout(TitlePanelLayout);
        TitlePanelLayout.setHorizontalGroup(
            TitlePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(TitlePanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(LogoLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 220, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(99, 99, 99)
                .add(FrameTitle, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 426, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(35, 35, 35))
        );
        TitlePanelLayout.setVerticalGroup(
            TitlePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(TitlePanelLayout.createSequentialGroup()
                .add(TitlePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(TitlePanelLayout.createSequentialGroup()
                        .add(4, 4, 4)
                        .add(LogoLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .add(TitlePanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .add(FrameTitle, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 41, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );

        CartPanel.setBackground(new java.awt.Color(255, 255, 255));
        CartPanel.setPreferredSize(new java.awt.Dimension(150, 500));

        ItemLabel.setFont(new java.awt.Font("Tahoma", 0, 12));
        ItemLabel.setText("Items in Cart: ");

        NumberLabel.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        NumberLabel.setText("0");

        LoginButton.setFont(new java.awt.Font("Tahoma", 0, 18));
        LoginButton.setText("Add Card");
        LoginButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                LoginButtonActionPerformed(evt);
            }
        });

        SearchButton.setFont(new java.awt.Font("Tahoma", 0, 18));
        SearchButton.setText("Search");
        SearchButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SearchButtonActionPerformed(evt);
            }
        });

        ViewCartButton.setFont(new java.awt.Font("Tahoma", 0, 18));
        ViewCartButton.setText("View Cart");
        ViewCartButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ViewCartButtonActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout CartPanelLayout = new org.jdesktop.layout.GroupLayout(CartPanel);
        CartPanel.setLayout(CartPanelLayout);
        CartPanelLayout.setHorizontalGroup(
            CartPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(CartPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(CartPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(CartPanelLayout.createSequentialGroup()
                        .add(ItemLabel)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(NumberLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 23, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(LoginButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 88, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(CartPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                        .add(org.jdesktop.layout.GroupLayout.LEADING, ViewCartButton, 0, 0, Short.MAX_VALUE)
                        .add(org.jdesktop.layout.GroupLayout.LEADING, SearchButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 88, Short.MAX_VALUE)))
                .addContainerGap(26, Short.MAX_VALUE))
        );
        CartPanelLayout.setVerticalGroup(
            CartPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, CartPanelLayout.createSequentialGroup()
                .add(84, 84, 84)
                .add(LoginButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 54, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(76, 76, 76)
                .add(SearchButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 52, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 79, Short.MAX_VALUE)
                .add(ViewCartButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 49, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(18, 18, 18)
                .add(CartPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(NumberLabel)
                    .add(ItemLabel))
                .add(73, 73, 73))
        );

        DynamicPanel.setMaximumSize(new java.awt.Dimension(650, 500));
        DynamicPanel.setPreferredSize(new java.awt.Dimension(650, 500));
        DynamicPanel.setSize(new java.awt.Dimension(650, 500));

        org.jdesktop.layout.GroupLayout DynamicPanelLayout = new org.jdesktop.layout.GroupLayout(DynamicPanel);
        DynamicPanel.setLayout(DynamicPanelLayout);
        DynamicPanelLayout.setHorizontalGroup(
            DynamicPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 650, Short.MAX_VALUE)
        );
        DynamicPanelLayout.setVerticalGroup(
            DynamicPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 500, Short.MAX_VALUE)
        );

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));
        jPanel1.setBounds(new java.awt.Rectangle(0, 0, 100, 100));
        jPanel1.setPreferredSize(new java.awt.Dimension(800, 30));

        NameLabel.setBackground(new java.awt.Color(255, 255, 255));
        NameLabel.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        NameLabel.setText("Log In Now!");

        ISLabel.setFont(new java.awt.Font("Lucida Console", 0, 11));
        ISLabel.setText("Powered by Interactive Solutions");

        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .add(25, 25, 25)
                .add(ISLabel)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 426, Short.MAX_VALUE)
                .add(NameLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 176, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                .add(ISLabel)
                .add(NameLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 31, Short.MAX_VALUE))
        );

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(TitlePanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 800, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
            .add(layout.createSequentialGroup()
                .add(CartPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(DynamicPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
            .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(TitlePanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 70, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                    .add(CartPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(DynamicPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 33, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void LoginButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LoginButtonActionPerformed
        // TODO add your handling code here:
        controller.AddStoreCardScreen();
}//GEN-LAST:event_LoginButtonActionPerformed

    private void SearchButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SearchButtonActionPerformed
        // TODO add your handling code here:
        controller.SearchChoiceScreen();
    }//GEN-LAST:event_SearchButtonActionPerformed

    private void ViewCartButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ViewCartButtonActionPerformed
        // TODO add your handling code here:
        controller.CartScreen();
    }//GEN-LAST:event_ViewCartButtonActionPerformed


    public void changeTitle(String newTitle){
        FrameTitle.setText(newTitle);
    }

    public void changeScreen(JPanel panel){
        DynamicPanel.removeAll();
        DynamicPanel.add(panel);
        DynamicPanel.validate();
        NumberLabel.setText(controller.getNumItemsInCart());
    }

    public void Login(String firstName){
        NameLabel.setText("Welcome " + firstName + "!");
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel CartPanel;
    private javax.swing.JPanel DynamicPanel;
    private javax.swing.JLabel FrameTitle;
    private javax.swing.JLabel ISLabel;
    private javax.swing.JLabel ItemLabel;
    private javax.swing.JButton LoginButton;
    private javax.swing.JLabel LogoLabel;
    private javax.swing.JLabel NameLabel;
    private javax.swing.JLabel NumberLabel;
    private javax.swing.JButton SearchButton;
    private javax.swing.JPanel TitlePanel;
    private javax.swing.JButton ViewCartButton;
    private javax.swing.JPanel jPanel1;
    // End of variables declaration//GEN-END:variables

}
